<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>
        {if empty($username)}
        会员数据
        {else}
        代理报表
        {/if}
    </title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/resource/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/resource/layuiadmin/style/admin.css" media="all">
</head>
<body>

<!-- 主体内容 -->
<div id="LAY_app">
    

    <div class="layadmin-tabsbody-item layui-show agentDetailList" style="background-color: #e3e3e3;">
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card" style="padding: 10px;">
                        <form class="layui-form search">
                            <div class="layui-form-item">
                             
                                <div class="layui-inline">
                                    <label class="layui-form-label">时间</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="datetime_range" class="layui-input" readonly>
                                    </div>
                                </div>
                                <div class="layui-inline" style="text-align: center;">
                                    <input type="hidden" name="uid" value="{$uid}" class="layui-input">
                                    <button type="button" class="layui-btn" id="layui-btn1"
                                            data-type="search">搜索</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="layui-row layui-col-space15">
                {if empty($username)}
                <label class="layui-form-label" style="text-align: center;padding-bottom: 26px;width:100%;">会员数据</label>
                {else}
                <label class="layui-form-label" style="text-align: center;padding-bottom: 26px;width:100%;">数据统计-{$username}</label>
                {/if}
            </div>


            
            
            <div class="layui-card agentSumm" >
                
                <div class="layui-card-body layuiadmin-card-list">
                   
                    <table id="agentSumm" lay-filter="agentSumm"></table>
                    <p class="layuiadmin-big-font"></p>
                </div>
            </div>
            {if !empty($username)}
            <table id="agentDetailList" lay-filter="agentDetailList"></table>
            {/if}
        </div>
    </div>

</div>
<script type="text/html" id="action">
    <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-xs" lay-event="userTaskList">NFT碎片买卖订单</button>
    </div>
</script>
<script src="/resource/layuiadmin/layui/layui.js"></script>
<script src="/resource/js/manage/init_date.js"></script>
<script src="/manage/user.js"></script>
<script src="./layui/layui/layui.js"></script>
<script>
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use(['element', 'table', 'form'], function() {
        var form = layui.form;
        var element = layui.element;
        var $ = layui.$;
        var table = layui.table;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#datetimeRange',
            type: 'datetime',
            range: true
        });
        var uide = document.getElementsByName("uid")[0];
        var uid = uide.value;
        //-----------------------个人
        table.render({
            elem: '#agentDetailList',
            title: "代理用户列表",
            url: '/manage/useragent/agentDetail?uid='+uid,
            method: 'get',
            cols: [
                [
                    //表头
                    {
                        field: 'id',
                        title: 'ID'
                    },{
                    field: 'username',
                    title: '账号'
                },{
                    field: 'balance',
                    title: '余额'
                },
                    {title: '操作', width: '20%', toolbar: '#action'}
                ]
            ],
            cellMinWidth: 10,
            totalRow: true,
            page: {
                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            },
            skin: 'row' //行边框风格
            ,
            even: true //开启隔行背景

        });
        table.render({
            elem: '#agentSumm',
            title: "代理统计",
            url: '/manage/useragent/agentSumm?uid='+uid,
            method: 'get',
            cols: [[
						{field: 'todayUserRegNum', title: '今日新增会员'}
                        ,{field: 'totalUserRegNum', title: '总会员数'}
                        ,{field: 'todayBuyMoeny', title: '今日买入NFT'}
                        ,{field: 'todaySaleMoney', title: '今日卖出NFT'}
                        ,{field: 'todayRechargeMoeny', title: '今日OTC转入'}
                        ,{field: 'todayWithMoeny', title: '今日OTC转出'}
                        ,{field: 'totalRechargeMoeny', title: '总OTC转入'}
                        ,{field: 'totalWithMoeny', title: '总OTC转出'}
                        ,{field: 'totalProfile', title: 'USTD存取差'}
					]],
            page: {
                layout: []
            }

        });
        // 监听工具条
        table.on('tool(agentDetailList)', function(obj){
            switch (obj.event) {
                case 'userTaskList':
                    layer.open({
                            type: 2,
                            area: ['80%', '80%'],
                            title: 'NFT碎片买卖订单',
                            content: '/manage/Bet/userTaskList?uid='+obj.data.id
                    });
                    break;
            }
				
        });
        active1 = {
            search: function() {
                console.log('搜索')
                //执行重载
                table.reload('agentDetailList', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    },
                    where: {
                        uid:uid,
                        username: $("input[name='username']").val(),
                        state: $("select[name='state'] option:selected").val(),
                        datetime_range: $("input[name='datetime_range']").val(),
                    }
                }, 'data');

                table.reload('agentSumm', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    },
                    where: {
                        uid:uid,
                        datetime_range: $("input[name='datetime_range']").val(),
                    }
                }, 'data');

                
            }
        };

        $('.agentDetailList #layui-btn1').on('click', function() {
            var type = $(this).data('type');
            active1[type] ? active1[type].call(this) : '';
        });
    });
</script>
</body>
</html>
